fix: handle different error format for map status#744
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes error handling for map status operations when some firmware versions return error-only responses without a 'result' key. The changes enable proper exception handling for the -10007 error code ("invalid status"/action locked) that occurs when attempting to switch maps while the device is in a forbidden state.
Changes:
- Updated V1 protocol decoder to handle error-only responses (no 'result' key)
- Added utility function to extract V1 API error codes from exceptions
- Added error handling in home trait to treat -10007 errors during map switching as a "busy" condition
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| roborock/protocols/v1_protocol.py | Enhanced error handling to preserve API errors when 'result' key is missing and renamed exc to api_error for clarity |
| roborock/devices/traits/v1/common.py | Added extract_v1_api_error_code utility to extract error codes from V1 RPC exceptions |
| roborock/devices/traits/v1/home.py | Added try-catch around map switching to convert -10007 errors into RoborockDeviceBusy exceptions |
| tests/protocols/test_v1_protocol.py | Added test for decoding error-only responses without 'result' key |
| tests/devices/traits/v1/test_home.py | Added integration test verifying fallback behavior when map switching is locked |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mock_map_rpc_channel: AsyncMock, | ||
| device_cache: DeviceCache, | ||
| ) -> None: | ||
| """Test that refresh falls back to current map when map switching is locked.""" |
There was a problem hiding this comment.
Corrected spelling of 'apropriate' to 'appropriate' (note: this occurs in the PR description, not in code)
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
Relates to #160952
error format seemingly is different for some api/ some firmware. This allows us to handle it better and successfully return a apropriate exception on the map logic.